package yun.web.activerecord.tx;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class TxEnableCondition implements Condition {
    /*
     * 配置文件中, datasource节点不为null则启用@Tx 拦截
     * */
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        String datasource = context.getEnvironment().getProperty("datasource");
        return datasource != null;
    }
}
